<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body {
            margin: 0;
            padding: 0;
        }

        #container {
            height: 100vh;
        }

        .bg {
            position: absolute;
            width: 100%;
            height: 100%;
        }

        .sun {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 600px;
            height: 600px;
            background-color: orange;
            border-radius: 50%;
        }

        .moon {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(calc(-50% + -160px), calc(-50% + -180px));
            width: 600px;
            height: 600px;
            box-shadow: 160px 180px 0 cyan;
            border-radius: 50%;
        }

        .sea {
            position: absolute;
            bottom: 0;
            width: 100%;
            height: 35%;
            backdrop-filter: blur(100px);
            -webkit-backdrop-filter: blur(100px);
            z-index: 100;
        }

        .sun-box,
        .moon-box,
        .bg {
            transition: 1s ease-in-out;
        }

        .sun-box,
        .moon-box {
            position: relative;
            overflow: hidden;
        }

        .light .sun-box {
            height: 100%;
        }

        .light .moon-box {
            height: 0;
        }

        .light .bg {
            background-color: #ffeea2;
        }

        .dark .sun-box {
            height: 0;
        }

        .dark .moon-box {
            height: 100%;
        }

        .dark .bg {
            background-color: #040720;
        }

        .btn-box {
            position: absolute;
            top: 5px;
            right: 100px;
            z-index: 999;
            display: flex;
        }

        .btn-box div {
            width: 90px;
            height: 40px;
            background: rgba(255, 255, 255, 0.7);
            margin: 5px;
            line-height: 40px;
            text-align: center;
            font-size: 14px;
            border-radius: 5px;
            cursor: pointer;
        }

        .btn-box div:hover {
            background: #fff;
        }
    </style>


</head>

<body>
    <div class="btn-box">
        <div class="sunBtn">
            <span class="iconfont icon-taiyang"></span> 白天模式
        </div>
        <div class="moonBtn">
            <span class="iconfont icon-moon"></span> 黑夜模式
        </div>
    </div>

    <div class="dark" id="container">
        <div class="bg"></div>
        <div class="moon-box">
            <div class="moon"></div>
        </div>
        <div class="sun-box">
            <div class="sun"></div>
        </div>
        <div class="sea"></div>
    </div>

    <script type="script/javascript" lang="javascript">
        
        const sunBtn = document.querySelector('.sunBtn')
const moonBtn = document.querySelector('.moonBtn')

sunBtn.addEventListener('click', function () {
    document.getElementById('container').setAttribute('class', 'light');
})

moonBtn.addEventListener('click', function () {
    document.getElementById('container').setAttribute('class', 'dark');
})

    </script>
</body>

</html>